package com.qixin.total.controller;


import com.alibaba.fastjson.JSONObject;
import com.qixin.api.bean.*;
import com.qixin.api.service.ComMoneyInfoService;
import com.qixin.api.service.ComPtUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 资金明细表 前端控制器
 * </p>
 *
 * @author 吕正睿
 * @since 2018-11-15
 */
@Controller
@RequestMapping("/comMoneyInfo")
public class ComMoneyInfoController {
	private Logger logger = LoggerFactory.getLogger(ComMoneyInfoController.class);
	@Autowired
	ComMoneyInfoService comMoneyInfoService;
@Autowired
ComPtUserService comPtUserService;
	/*
	跳转界面企业充值
	 */
	@RequestMapping("/main.html")
	public String carftl() { return "pingtai/Recharge_company"; }
/*
跳转分钱
 */
@RequestMapping("/Recycle")
public String Recycle() { return "pingtai/Recycle"; }
/*
跳转收钱
 */
@RequestMapping("/assing.html")
public String assing() { return "pingtai/Assing"; }
	/*
		充值企业查询
		 */
	@RequestMapping("/list")
	@ResponseBody
	public ResultPage<ComPtUser> list(VoPage voPage, HttpSession session, ComPtUser comPtUser) {
		ResultPage<ComPtUser> resultPage= comPtUserService.selectMyPage(voPage,session,comPtUser);
		return  resultPage;
	}
	/*
	分配资金
	 */
	@RequestMapping("/assing")
	@ResponseBody
	public boolean assing(HttpSession session,Double moeny,Long peopleId){

   Boolean addmoney=comPtUserService.addmoney(session,moeny,peopleId);
if (addmoney){
	return true;
}
return false;
	}
	/*
	回收资金
	 */
	@RequestMapping("/recycle")
	@ResponseBody
	public boolean recycle(HttpSession session,Double moeny,Long peopleId){

		Boolean offmoney=comPtUserService.offmoney(session,moeny,peopleId);
		if (offmoney){
			return true;
		}
		return false;
	}


	/**
	 * 查询充值
	 * @param voPage
	 * @return
	 */
	@RequestMapping("/RechargeList")
	@ResponseBody
	public ResultPage<ComMoneyInfo> RechargeList(VoPage voPage){
		ComMoneyInfo comMoneyInfo=new ComMoneyInfo();
		return comMoneyInfoService.selectMyPageAll(voPage,comMoneyInfo);
	}

	/*
	充值记录查询
	 */
	@RequestMapping("/query")
	@ResponseBody
	public ResultPage<ComMoneyInfo> query(VoPage voPage,String param){
		logger.info(param);
		Map map = JSONObject.parseObject(param);
		ResultPage<ComMoneyInfo> resultPage=comMoneyInfoService.query(map,voPage);
		return resultPage;
	}

}

